import { Roles } from "utils/creep/setups";
  /*
     ooooo
    oeeeeeo
    osoeoso
    oceleco
    oeoeoeo
    oeeseeo
     ooooo
    */
export class  SpawnLayout
{
    static transferSpawn:IFVector2[]=[{x:1,y:2},{x:5,y:2}];
    static SpawnPos:IFVector2[]=[{x:1,y:2},{x:5,y:2},{x:3,y:5}];
    static  LinkPos:IFVector2={x:3,y:3};
    static SpawnDirection:DirectionConstant[]=[BOTTOM,BOTTOM]; // transfer的方向
    // 孵化爬的朝向
    static SpawmDirs:{[key:string]:DirectionConstant[]}={1:[TOP_LEFT,LEFT,BOTTOM_LEFT],3:[BOTTOM,BOTTOM_LEFT,BOTTOM_RIGHT],5:[TOP_RIGHT,RIGHT,BOTTOM_RIGHT]};
    // 爬所在位置对于的工作区域
    static  ExtensionAndSpawnMap:{[key in number]:{[key in number]:IFVector2[]}}={
        2:{
            2: [ {x:-1,y:-1},{x:-1,y:0},{x:0,y:-1},{x:1,y:-1},{x:1,y:0}, {x:0,y:1} ],
            4: [ {x:0,y:-1},{x:-1,y:0},{x:-1,y:1},{x:0,y:1} ]
            },
        4:{
            2: [ {x:0,y:-1},{x:1,y:-1},{x:1,y:0},{x:0,y:1}  ],
            4: [ {x:-1,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1} ]
            }
    };
    static  containeridx:IFVector2[]=[ {x:1,y:3}, {x:5,y:3}];
    static  MiniCreepWorkPos:IFVector2[]=[ {x:2,y:2}, {x:2,y:4}, {x:4,y:2}, {x:4,y:4}];
    static MiniQueenToSpawn:Record<number,Record<number,IFVector2>>={
        2:{
            2:{x:1,y:2},
            4: {x:3,y:5}
            },
        4:{
            2:{x:5,y:2},
            4: {x:3,y:5}
            }
    };

    public static  formatVector(p:IFVector2)
    {
        return `${p.x}/${p.y}`
    }
    public static parseVector(str:string):IFVector2
    {
        const arr = str.split('/');
        if(arr.length!==2)
        {
            throw new Error(`解析错误:${str}`);
        }
        return {x:parseInt(arr[0]),y:parseInt(arr[1])}
    }

    public static getEnergyPos(p:IFVector2)
    {
        if(p.x<3)
        {
            return [ {x:3,y:3},{x:1,y:3} ]
        }
        else
        {
            return  [  {x:3,y:3}, {x:5,y:3}]
        }
    }
}

/**
 * 保证房间能够启动的基本运行配置
 */
export  const fillerConfig:Record<string,number>={
    1:0,
    2:1,
    3:3,
    4:4,
    5:4,
    6:4,
    7:4,
    8:4,
}

export const SpawnLayoutConfig= SpawnLayout;